const {MyPromise} = require('./发布订阅模式')
/**
 * 执行顺序 console.log(1) ---> setTimeout(回调没执行)--->then方法-->setTimeout的回调--》resolve(10)
 * * 存在的问题是必须resolve完再去执行then方法
 */
// new MyPromise((resolve, reject) => {
//   setTimeout(() => {
//     resolve(10)
//   })
// }).then(res=>{console.log('second',res);}, reason => {console.log(reason);})

/**
 * 发布订阅模式
 * * 打印结果为 second 10
 */
let p = new MyPromise((resolve, reject) => {
  setTimeout(() => {
    resolve(10)
  })
})
p.then(res => {console.log(res + 1);})
p.then(res => {console.log(res + 2);})
p.then(res => {console.log(res + 3);})  // 11 12 13


